<?php
	chong_pha_hoai();
?>
<div class="title_contain">
	TRANG GIỎ HÀNG
</div>
<style>
	span.jjj_gio_hang
	{
		margin-left:5px
	}
</style>
<?php
	$so_8=count($_SESSION[$ten_danh_dau.'id_giohang']);
	$mua_hang="khong";
	for($r=0;$r<$so_8;$r++)
	{
		$solg=$_SESSION[$ten_danh_dau.'solg_abc'][$r];
		if($solg!=0)
		{
			$mua_hang="co";
		}
	}
	if($mua_hang=="khong")
	{
		unset($_SESSION[$ten_danh_dau.'id_giohang']);
		unset($_SESSION[$ten_danh_dau.'solg_abc']);
	}
	if($so_8!=0 and $mua_hang=="co")
	{
?>
	<center>
		<form action="" method="post" style="margin:0">
			<table width="640px" border="0">
			  <tr style="background-color:#666666;color:#FFFFFF;font-weight:bold;">
				<td align="center" width="50px">STT</td>
				<td width="250px"><span class="jjj_gio_hang">Tên sản phẩm</span></td>
				<td width="100px"><span class="jjj_gio_hang">Số lượng</span></td>
				<td width="120px"><span class="jjj_gio_hang">Đơn giá</span></td>
				<td width="120px"><span class="jjj_gio_hang">Tổng số</span></td>
			  </tr>
			  <?php
				$tong_lon=0;
				$so=count($_SESSION[$ten_danh_dau.'id_giohang']);
				for($r=0;$r<$so;$r++)
				{
					$q=$r+1;
					$solg=$_SESSION[$ten_danh_dau.'solg_abc'][$r];
					$id_sp=$_SESSION[$ten_danh_dau.'id_giohang'][$r];
					$tv="select * from sanpham where id_sanpham=$id_sp";
					$tv_1=mysql_query($tv);
					$tv_2=mysql_fetch_array($tv_1);
					$tong=$solg*$tv_2['dongia_sanpham'];
					$tong_lon=$tong_lon+$tong;
					$ten_input__solg="solg_kkk___$r";
					if($solg!=0)
					{
						?>
							<tr>
								<td align="center"><?php echo $q; ?></td>
								<td><span class="jjj_gio_hang"><?php echo $tv_2['ten_sanpham']; ?></span></td>
								<td><span class="jjj_gio_hang">
									<input style="width:50px" value="<?php echo $solg; ?>" name="<?php echo $ten_input__solg; ?>" />
								</span></td>
								<td><span class="jjj_gio_hang"><?php echo number_format($tv_2['dongia_sanpham'])."VNĐ"; ?></span></td>
								<td><span class="jjj_gio_hang"><?php echo number_format($tong)."VNĐ"; ?></span></td>
							</tr>
						<?php
					}
				}
			  ?>
			  <tr>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td align="center"><span class="jjj_gio_hang">
					<input type="hidden" name="cap_nhat_gio_hang_ggg" value="cap_nhat_gio_hang_ggg" />
					<input type="submit" value="Cập nhật" />
				</span></td>
				<td>&nbsp;</td>
				<td><?php echo "<b>".number_format($tong_lon)."VNĐ</b>"; ?></td>
			  </tr>
			</table>
		</form>
			<div class="cao_3_px"></div>
			<div class="cao_3_px"></div>
		<form action="" method="post" style="margin:0">
			<table width="640px" border="0">
				<tr style="background:#676767;color:white;font-weight:bold">
					<td colspan="2">
						<span class="jjj_gio_hang">Vui lòng điền đầy đủ thông tin bên dưới</span>
					</td>
				</tr>
				<tr>
					<td><b>Họ tên: </b></td>
					<td><input width="400px" name="hoten" /></td>
				</tr>
				<tr>
					<td><b>Địa chỉ: </b></td>
					<td>
						<textarea name="dchi" style="width:400px;height:65px;"></textarea>
					</td>
				</tr>
				<tr>
					<td><b>Điện thoại: </b></td>
					<td><input width="400px" name="dthoai" /></td>
				</tr>
				<tr>
					<td><b>Email: </b></td>
					<td><input width="400px" name="email" /></td>
				</tr>
				<tr>
					<td><b>Nội dung: </b></td>
					<td>
						<textarea name="noidung" style="width:400px;height:130px;"></textarea>
					</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>
						<input type="hidden" name="thanhtoan_hoadon_hhh" value="thanhtoan_hoadon_hhh" />
						<input type="submit" value="Thanh toán" />
					</td>
				</tr>
			</table>
		</form>
	</center>
<?php
	}//if $so_8
	else
	{
?>
	<center>
		<table width="735px" border="0">
		  <tr>
			<td>Bạn chưa mua hàng</td>
		  </tr>
		</table>
	</center>
<?php
	}
?>